﻿@model IEnumerable<eduscrum.ViewModels.UserStoryVM>
@using eduscrum.ViewModels

<h2>Product Backlog</h2>

<select id="backloglist" size="20" onchange="selectUserStory(this);">
    <option value="!add_user_story!" style="color:#339933;" selected="selected">Add User Story</option>
</select>

@{
    Html.RenderPartial("~/Views/UserStory/Create.cshtml", new UserStoryVM { Project = (ProjectVM)ViewData["Project"] });
    Html.RenderPartial("~/Views/UserStory/Edit.cshtml", new UserStoryVM { Project = (ProjectVM)ViewData["Project"] });
}

<script type="text/javascript">

    document.getElementById("tbl_editUserStory").style.display = "none";
    
    var userStories = new Array();
    var backlogList = document.getElementById("backloglist");
    var option;

    @foreach (var item in Model.OrderByDescending(u => u.Priority))
    {
        @:var us = new UserStory(@item.UserStoryID, "@Html.Raw(item.Title)", "@Html.Raw(item.Description)", @item.StoryPoints, @item.Priority);
        @:userStories.push(us);
        @:option = document.createElement("option");
        @:option.setAttribute("value", "@item.UserStoryID");
        @:option.innerHTML = "@item.Title";
        @:backlogList.appendChild(option);
    }

</script>
